package util;

import com.lmax.disruptor.WaitStrategy;

public enum WaitStrategysEnum {

    //blocking，sleeping，yielding，busyspin
    BLOCKING_WAIT("blocking",WaitStrategys.BLOCKING_WAIT),
    SLEEPING_WAIT("sleeping",WaitStrategys.SLEEPING_WAIT),
    YIELDING_WAIT("yielding",WaitStrategys.YIELDING_WAIT),
    BUSYSPIN_WAIT("busyspin",WaitStrategys.BUSYSPIN_WAIT);

    private String waitType;
    private WaitStrategy waitStrategy;

    WaitStrategysEnum(String waitType, WaitStrategy waitStrategy) {
        this.waitType = waitType;
        this.waitStrategy = waitStrategy;
    }

    public WaitStrategy getWaitStrategy(String waitType){
        WaitStrategysEnum[] values = WaitStrategysEnum.values();
        for(WaitStrategysEnum waitStrategysEnum : values){
            if(waitType.equalsIgnoreCase(waitStrategysEnum.getWaitType())){
                return waitStrategysEnum.getWaitStrategy();
            }
        }
        return null;
    }

    public String getWaitType() {
        return waitType;
    }

    public void setWaitType(String waitType) {
        this.waitType = waitType;
    }

    public WaitStrategy getWaitStrategy() {
        return waitStrategy;
    }

    public void setWaitStrategy(WaitStrategy waitStrategy) {
        this.waitStrategy = waitStrategy;
    }
}
